package com.ljfirst.多线程顺序执行;

import lombok.SneakyThrows;

/**
 * @author liujun
 * @version 1.0
 * @date 2020/12/2
 * @author—Email liujunfirst@outlook.com
 * @blogURL https://blog.csdn.net/ljfirst
 * @description 多线程顺序执行
 * 现在有T1、T2、T3三个线程，你怎样保证T2在T1执行完后执行，T3在T2执行完后执行?
 */
public class demo03 extends Thread{

    public demo03(String name){
        setName(name);
    }

    @SneakyThrows
    @Override
    public void run() {
        Thread.sleep(1_000);
        System.out.println("i am "+ this.currentThread().getName());
    }

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new demo03("t1");
        Thread t2 = new demo03("t2");
        Thread t3 = new demo03("t3");

        t1.start();
        t1.join();
        t2.start();
        t2.join();
        t3.start();
        t3.join();
    }
}
